import {
  Component, OnInit, ViewEncapsulation, ChangeDetectionStrategy, Input, ElementRef,
  Renderer, AfterContentInit
} from '@angular/core';
import {ToolsService} from "@shared/service/tools/tools.service";
import {GoodsImgRespVO} from "@interface/index";



@Component({
  selector: 'goods-slider',
  templateUrl: './slider.component.html',
  styleUrls: ['./slider.component.scss'],
  encapsulation: ViewEncapsulation.None,
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class GoodsSliderComponent implements OnInit, AfterContentInit {

  @Input() slider: Array<GoodsImgRespVO[]>;

  constructor(private ele: ElementRef,
              private tools: ToolsService,
              private renderer: Renderer) {
  }

  setEleRect() {
    const node = this.ele.nativeElement.getElementsByClassName('seed-sliders-warp'),
      winWidth = this.tools.getWindowSize().width;
    this.renderer.setElementStyle(node[0], 'height', `${winWidth}px`);
    this.renderer.setElementStyle(node[1], 'height', `${winWidth}px`);
  }

  ngAfterContentInit() {
    this.setEleRect();
  }

  ngOnInit() {
  }

}
